package com.lin.controller;

import com.lin.entity.Yunshu;
import com.lin.service.IYunshuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/yunshu")
@CrossOrigin(origins = "*")
public class YunshuController {
    @Autowired
    IYunshuService iYunshuService;


    @GetMapping(value = "/info",produces = {"application/json;charset=UTF-8"})
    public List<Yunshu> listYunshuInfo(){
        return iYunshuService.listYunshu();
    }


    @GetMapping(value = "/info/{id}",produces = {"application/json;charset=UTF-8"})
    public Yunshu YunshuInfoById(@PathVariable(value = "id")Integer id){
        return iYunshuService.selectYunshuById(id);
    }


    @PostMapping(value = "/add",produces = {"application/json;charset=UTF-8"})
    public void addYunshu(@RequestBody Yunshu yunshu){
        iYunshuService.insertYunshu(yunshu);
    }


    @PostMapping(value = "/remove/{id}",produces = {"application/json;charset=UTF-8"})
    public void removeYunshu(@PathVariable("id") Integer id){
        iYunshuService.deleteYunshuById(id);
    }


    @PostMapping(value = "/edit",produces = {"application/json;charset=UTF-8"})
    public void editYunshu(@RequestBody Yunshu yunshu
    ){
        iYunshuService.updateYunshu(yunshu);
    }

}